class Admin::OptionValuesController < Admin::BaseController
  
  def index
    list
    render :action => 'list'
  end  
  
  def list
    @option_values =  OptionValue.find(:all, :page => {:size => 10, :current =>params[:page], :first => 1})
  end

  def create
	@option_value = OptionValue.new(@params['option_value'])
    @option_value.save!
    flash[:notice] = 'Option value was successfully created.'
    redirect_to :action => 'list'    
  rescue
    logger.error("unable to create new option value: #{@option_value.inspect}")
    flash[:error] = ' Problem saving new option value'
    # error occurred while saving, give user a chance to save again
    render :action => 'new'
  end    

  def edit
    @option_value = OptionValue.find(@params[:id])
  end
  
  def update
    @option_value = OptionValue.find(@params[:id])
    if @option_value.update_attributes(@params[:option_value])
      flash[:notice] = 'Option value was successfully updated.'
      redirect_to :action => 'list'
    else
      render :action => 'list'
    end
  end
  
  def destroy
    OptionValue.find(params[:id]).destroy
    redirect_to :action => 'list'
  end
end